﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BusinessLogicLayer;

namespace logicunivesityinventorystore.Store
{
    public partial class Update_stock : System.Web.UI.Page
    {
        Item item;
        string categoryID;
        string itemID;
        protected void Page_Load(object sender, EventArgs e)
        {
            categoryID=ddlCategory.SelectedValue;
            if (!IsPostBack)
            {
             //   PopulateData();
            }
        }

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
        {
            PopulateData();
        }

        private void PopulateData()
        {
            itemID = ddlItem.SelectedValue;
            item = new ItemFacade().FindByItemID(itemID);
            txtReorderLevel.Text = item.ReorderLevel.ToString();
            txtReorderQty.Text = item.ReorderQty.ToString();
            txtBinNo.Text = item.Bin;
        }

        protected void btn_Save_Click(object sender, EventArgs e)
        {
            int reorderlevel = Convert.ToInt32(txtBinNo.Text);
            int reorderqty = Convert.ToInt32(txtReorderQty.Text);
            new ItemFacade().UpdateItem(itemID, reorderlevel, reorderqty,txtReorderLevel.Text);
        }
    }
}